package com.dzx.design.creational.singletonexample;

/**
 * @author dzx
 * @ClassName:
 * @Description:
 * @date 2019年07月15日 09:54:58
 */

/**
 * 懒汉式+双重检测同步锁
 */
public class SingletonExample3 {

    private SingletonExample3() {
    }

    public static volatile SingletonExample3 singletonExample3 = null;

    public static SingletonExample3 getInstance() {
        if (singletonExample3 == null) {
            synchronized (SingletonExample3.class) {
                if (singletonExample3 == null) {
                    singletonExample3 = new SingletonExample3();
                }
            }
        }
        return singletonExample3;
    }

}
